<template>
  <div class="app-container">
    <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane label="礼品配置" name="GiftConfig" />
      <el-tab-pane label="礼品概率配置" name="GiftProbilityConfig" />
      <div class="tab-content">
        <!-- <keep-alive> 组件name或者路由 -->
        <component :is="curTabcompnents[activeName]" />
        <!-- </keep-alive> -->
      </div>

    </el-tabs>
  </div>
</template>

<script>

import GiftConfig from './components/GiftConfig'
import GiftProbilityConfig from './components/GiftProbilityConfig'

export default {
  name: 'Tab',
  components: { GiftConfig, GiftProbilityConfig },
  data() {
    return {
      boxId: -1,
      price: -1,
      rebate: -1,
      boxPrice: -1,
      activeName: 'GiftConfig',
      curTabcompnents: {
        'GiftConfig': 'GiftConfig',
        'GiftProbilityConfig': 'GiftProbilityConfig'
      }
    }
  },
  watch: {
    activeName(val) {
      this.$router.push(`${this.$route.path}?tab=${val}&id=${this.boxId}&price=${this.price}&rebate=${this.rebate}&coinModel=${this.coinModel}`)
    }
  },
  created() {
    // init the default selected tab
    const tab = this.$route.query.tab
    this.boxId = this.$route.query.id
    this.price = this.$route.query.price
    this.rebate = this.$route.query.rebate
    this.coinModel = this.$route.query.coinModel
    this.$log(this.boxId, this.coinModel)
    if (tab) {
      this.activeName = tab
    }
  },
  methods: {
    handleClick(tab) {
      this.activeName = tab.name
    }
  }
}
</script>

<style lang="scss" scoped>
.app-container{
  padding:0px;
}

</style>
